﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebAPITest.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class HomeController : ControllerBase
    {
        public readonly ISingletonService _singletonService;
        public readonly ITransientService _transientService;
        public readonly IScopedService _scopedService;


        //构造函数注入
        /*public HomeController(ISingletonService singletonService)
        {
            _singletonService = singletonService;
        }

        public HomeController(ITransientService transientService)
        {
            _transientService = transientService;
        }

        public HomeController(IScopedService scopedService)
        {
            _scopedService = scopedService;
        }*/

       
        public HomeController(ISingletonService singletonService, ITransientService transientService, IScopedService scopedService)
        {
            _singletonService = singletonService;
            _transientService = transientService;
            _scopedService = scopedService;
        }

        [HttpGet]
        //方法注入
       
        public void GetAllBooks([FromServices] ISingletonService singletonService,[FromServices] ITransientService transientService,[FromServices] IScopedService scopedService)
        {
            singletonService.GetAllBooks();
            transientService.GetAllBooks();
            scopedService.GetAllBooks();
        }



        //需求:利用过滤器统一给接口的参数 判断有无异常关键字
        //(用判断字符串是否包含”哈"这个字来代替这个逻辑)
        //提示可以使用 context.HttpContext.Request.Query 来获取接口请求的所有Query参数
        //发送信息
        [HttpGet]
        public void SendMessage(string message,int memberId)
        {
            

        }
        //发送评论
        [HttpGet]
        public void SendComment(string message,int vodId)
        {

        }
        
    }





}
